6 #ifndef _CFEXPSOLVER_H_ 7 #define _CFEXPSOLVER_H_ 34 virtual void Start() = 0;
37 virtual void End() = 0;
40 virtual void RmvModel(
const std::string & key ) = 0;
54 check_node(
const std::vector<t_fexpcommon_ct> & min_bound,
const std::vector<t_fexpcommon_ct> & max_bound);
66 template<
typename TValue,
typename Enable =
void>
70 template<
typename TExpCalc>
72 <TExpCalc, typename std::enable_if<std::is_base_of<ICFEXPExplicitCalcBase, TExpCalc>::value>::type>
80 virtual void Start()
override;
98 template<
typename TExpCalc>
102 _calculator(
CFEXPDataManager<TExpCalc>::SafeAllocInstance(builder->GetModelContainer(), _exporter,
103 [this] { update_topology_map_for_contact(); }, [
this](
auto in1,
auto in2) {
return check_node(in1, in2); })) { }
107 template<
typename TExpCalc>
114 auto result_saved =
false;
146 _calculator->SetNewTimeStep(_calculator->GetCalculatedCriticTimeStep());
149 catch (
const std::exception & ex)
165 #define START_THREAD_ID 1 191 size_t _threads_number;
221 #define PARRALEL_SOLVER_THREAD_TEMPLATE_DEF(cls_thread, cls_data) cls_thread<void(size_t, Ptr<cls_data>), size_t, Ptr<cls_data>> 223 #define SIMPLE_PARALLEL_SOLVER CFEXPParallelSolver<CFEXPCalculation, CFEXPSolverThreadInputData, PARRALEL_SOLVER_THREAD_TEMPLATE_DEF(CFEXPCppThread, CFEXPSolverThreadInputData), CFEXPThreadGeneralBarrier> 225 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier,
typename Enable =
void>
229 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
232 <TExpCalc, TThreadData, TThread, Tbarrier, typename std::enable_if<
233 std::is_base_of<ICFEXPExplicitCalcBase , TExpCalc >::value &&
234 std::is_base_of<ICFEXPThreadDataBase , TThreadData>::value &&
235 std::is_base_of<ICFEXPThreadBase , TThread >::value &&
236 std::is_base_of<ICFEXPSynchrThreadBarrier, Tbarrier >::value>::type>
243 virtual void Start()
override;
256 enum ESynchronization { eSync1, eSync2, eSync3, eSync4, eSync5, eSync6, eSync7, eSync8, eSync9, eSync10, eSync11, eSyncCount };
257 void Synchronize(ESynchronization barrier);
275 void update_model_mapping (
size_t thread_id);
282 void try_export_calculation_results(
Ptr<TThreadData> data,
size_t thread_id);
287 std::mutex _mtx_stuct_map_update;
288 volatile size_t _thread_counter_stuct_map_update;
290 std::mutex _mtx_dt_update;
291 volatile size_t _thread_counter_dt_update;
293 std::mutex _mtx_time_synchr;
294 volatile size_t _thread_counter_time_synchr;
296 std::mutex _mtx_save_res_synchr;
297 volatile size_t _thread_counter_save_res_synchr;
299 std::mutex _mtx_calc_end_synchr;
300 volatile size_t _thread_counter_calc_end_synchr;
310 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
312 std::is_base_of<ICFEXPExplicitCalcBase , TExpCalc >::value &&
313 std::is_base_of<ICFEXPThreadDataBase , TThreadData>::value &&
314 std::is_base_of<ICFEXPThreadBase , TThread >::value &&
315 std::is_base_of<ICFEXPSynchrThreadBarrier, Tbarrier >::value>::type>
321 _builder->GetModelContainer()->GetModelElement(ICFEXPSetting::ESettingType::eModelBase,
ESystemElementType::eSetting))->GetThreadNumber();
323 initialize(threads,
FEXPCOMMON_DEFAULT_VALUE, ESynchronization::eSync9, [
this](
auto val1,
auto val2,
auto val3) {
return get_thread_instance(val1, val2, val3); });
327 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
329 std::is_base_of<ICFEXPExplicitCalcBase , TExpCalc >::value &&
330 std::is_base_of<ICFEXPThreadDataBase , TThreadData>::value &&
331 std::is_base_of<ICFEXPThreadBase , TThread >::value &&
332 std::is_base_of<ICFEXPSynchrThreadBarrier, Tbarrier >::value>::type>
334 size_t no_calc_threads, ESynchronization last_barrier, t_ThrdInstGetter thrd_inst_gttr)
338 #define PARALLEL_SOLVER_ERROR_THREADS "Error: Try exclude too much threads \"" 341 auto threads_setting_num = setting->GetThreadNumber();
342 if (threads_setting_num <= no_calc_threads)
345 error +=
"--> Allowable number of threads is \"" + CFEXPBaseConvers::NumberToString<size_t>(threads_setting_num) +
"\".";
349 setting->SetThreadNumber(threads_setting_num - no_calc_threads);
354 initialize(setting->GetThreadNumber(), no_calc_threads, last_barrier, thrd_inst_gttr);
358 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
359 void CFEXPParallelSolver<TExpCalc, TThreadData, TThread, Tbarrier,
typename std::enable_if<
360 std::is_base_of<ICFEXPExplicitCalcBase , TExpCalc >::value &&
361 std::is_base_of<ICFEXPThreadDataBase , TThreadData>::value &&
362 std::is_base_of<ICFEXPThreadBase , TThread >::value &&
363 std::is_base_of<ICFEXPSynchrThreadBarrier, Tbarrier >::value>::type>
364 ::initialize(
size_t threads,
size_t no_calc_threads, ESynchronization last_barrier, t_ThrdInstGetter thrd_inst_gttr)
375 auto thread_id = *_thread_data->GetThreadId().get();
auto calc_thread_num = thread_id.size();
381 _thread_map.insert(
MAP_PAIR(
id, thrd_inst_gttr(
id, _thread_data,
true)));
384 [
this] { update_topology_map_for_contact(); }, [
this](
auto in1,
auto in2) {
return check_node(in1, in2); })));
393 if (_thread_map.count(++thread_id_gen))
395 _thread_map.insert(
MAP_PAIR(thread_id_gen, thrd_inst_gttr(thread_id_gen, _thread_data,
false)));
406 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
407 void CFEXPParallelSolver<TExpCalc, TThreadData, TThread, Tbarrier,
typename std::enable_if<
408 std::is_base_of<ICFEXPExplicitCalcBase , TExpCalc >::value &&
409 std::is_base_of<ICFEXPThreadDataBase , TThreadData>::value &&
410 std::is_base_of<ICFEXPThreadBase , TThread >::value &&
411 std::is_base_of<ICFEXPSynchrThreadBarrier, Tbarrier >::value>::type>
420 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
422 std::is_base_of<ICFEXPExplicitCalcBase , TExpCalc >::value &&
423 std::is_base_of<ICFEXPThreadDataBase , TThreadData>::value &&
424 std::is_base_of<ICFEXPThreadBase , TThread >::value &&
425 std::is_base_of<ICFEXPSynchrThreadBarrier, Tbarrier >::value>::type>
426 ::get_thread_instance(
size_t id,
Ptr<TThreadData> data,
bool is_calc_thread)
430 [
this](
auto it1,
auto it2) { CFEXPParallelSolver::thread_Calculation_function(it1, it2); }, id, data);
434 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
435 void CFEXPParallelSolver<TExpCalc , TThreadData, TThread, Tbarrier,
typename std::enable_if<
436 std::is_base_of<ICFEXPExplicitCalcBase , TExpCalc >::value &&
437 std::is_base_of<ICFEXPThreadDataBase , TThreadData>::value &&
438 std::is_base_of<ICFEXPThreadBase , TThread >::value &&
439 std::is_base_of<ICFEXPSynchrThreadBarrier, Tbarrier >::value>::type>
445 bool calculation_end =
false;
auto calculator = get_calculator(thread_id);
449 data->SetCalcTimeIncrement(thread_id, calculator->SimulationTimeIncrement(thread_id));
450 Synchronize(ESynchronization::eSync1);
453 check_time_synchronization(data);
455 calculation_end = check_calculation_end(data, thread_id);
456 Synchronize(ESynchronization::eSync2);
460 Synchronize(ESynchronization::eSync3);
462 calculator->PrepareDataForNewTimeLevel(thread_id);
465 update_model_mapping(thread_id);
467 calculator->GlobalToLocalTransformation(thread_id);
468 Synchronize(ESynchronization::eSync4);
470 calculator->CalculateForces(thread_id);
471 Synchronize(ESynchronization::eSync5);
473 calculator->CalculateNewGeometry(thread_id);
474 Synchronize(ESynchronization::eSync6);
476 try_export_calculation_results(data, thread_id);
478 calculator->PrintOutResults(thread_id);
479 Synchronize(ESynchronization::eSync7);
481 calculator->StabilityControl(thread_id);
482 data->SetTimeStep(thread_id, calculator->GetCalculatedCriticTimeStep());
483 Synchronize(ESynchronization::eSync8);
486 update_time_step(data);
488 Synchronize(ESynchronization::eSync9);
491 catch (
const std::exception & ex)
502 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
504 std::is_base_of<ICFEXPExplicitCalcBase , TExpCalc >::value &&
505 std::is_base_of<ICFEXPThreadDataBase , TThreadData>::value &&
506 std::is_base_of<ICFEXPThreadBase , TThread >::value &&
507 std::is_base_of<ICFEXPSynchrThreadBarrier, Tbarrier >::value>::type>
508 ::get_calculator(
size_t thread_id)
511 return _calculator_map[thread_id];
515 #define THREAD_COUNT_UPDATER 1 517 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
518 void CFEXPParallelSolver<TExpCalc, TThreadData, TThread, Tbarrier,
typename std::enable_if<
519 std::is_base_of<ICFEXPExplicitCalcBase , TExpCalc >::value &&
520 std::is_base_of<ICFEXPThreadDataBase , TThreadData>::value &&
521 std::is_base_of<ICFEXPThreadBase , TThread >::value &&
522 std::is_base_of<ICFEXPSynchrThreadBarrier, Tbarrier >::value>::type>
523 ::update_model_mapping(
size_t thread_id)
527 std::unique_lock<std::mutex> lock(_mtx_stuct_map_update, std::defer_lock);
529 ++_thread_counter_stuct_map_update;
531 get_calculator(thread_id)->UpdateModelMapping(thread_id);
532 if (_thread_counter_stuct_map_update == _threads)
538 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
539 void CFEXPParallelSolver<TExpCalc, TThreadData, TThread, Tbarrier,
typename std::enable_if<
540 std::is_base_of<ICFEXPExplicitCalcBase , TExpCalc >::value &&
541 std::is_base_of<ICFEXPThreadDataBase , TThreadData>::value &&
542 std::is_base_of<ICFEXPThreadBase , TThread >::value &&
543 std::is_base_of<ICFEXPSynchrThreadBarrier, Tbarrier >::value>::type>
548 std::unique_lock<std::mutex> lock(_mtx_dt_update, std::defer_lock);
550 ++_thread_counter_dt_update;
553 auto min_dt = data->GetMinTStep();
556 if (_calculator_map.count(
IT.first))
557 _calculator_map[
IT.first]->SetNewTimeStep(min_dt);
560 if (_thread_counter_dt_update == _threads)
566 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
567 void CFEXPParallelSolver<TExpCalc, TThreadData, TThread, Tbarrier,
typename std::enable_if<
568 std::is_base_of<ICFEXPExplicitCalcBase , TExpCalc >::value &&
569 std::is_base_of<ICFEXPThreadDataBase , TThreadData>::value &&
570 std::is_base_of<ICFEXPThreadBase , TThread >::value &&
571 std::is_base_of<ICFEXPSynchrThreadBarrier, Tbarrier >::value>::type>
576 std::unique_lock<std::mutex> lock(_mtx_time_synchr, std::defer_lock);
578 ++_thread_counter_time_synchr;
581 data->CheckCalcTimeConsistency();
582 if (_thread_counter_time_synchr == _threads)
588 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
589 void CFEXPParallelSolver<TExpCalc, TThreadData, TThread, Tbarrier,
typename std::enable_if<
590 std::is_base_of<ICFEXPExplicitCalcBase , TExpCalc >::value &&
591 std::is_base_of<ICFEXPThreadDataBase , TThreadData>::value &&
592 std::is_base_of<ICFEXPThreadBase , TThread >::value &&
593 std::is_base_of<ICFEXPSynchrThreadBarrier, Tbarrier >::value>::type>
598 std::unique_lock<std::mutex> lock(_mtx_save_res_synchr, std::defer_lock);
600 ++_thread_counter_save_res_synchr;
603 auto calculator = get_calculator(thread_id);
608 if (_thread_counter_save_res_synchr == _threads)
614 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
615 bool CFEXPParallelSolver<TExpCalc, TThreadData, TThread, Tbarrier,
typename std::enable_if<
616 std::is_base_of<ICFEXPExplicitCalcBase , TExpCalc >::value &&
617 std::is_base_of<ICFEXPThreadDataBase , TThreadData>::value &&
618 std::is_base_of<ICFEXPThreadBase , TThread >::value &&
619 std::is_base_of<ICFEXPSynchrThreadBarrier, Tbarrier >::value>::type>
623 auto calculator = get_calculator(thread_id);
625 auto result = calculator->CheckEnd(thread_id);
626 data->SetIsEnd(thread_id, result);
628 std::unique_lock<std::mutex> lock(_mtx_calc_end_synchr, std::defer_lock);
630 ++_thread_counter_calc_end_synchr;
634 if (result && !_result_saved.load())
641 if (_thread_counter_calc_end_synchr == _threads)
648 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
649 void CFEXPParallelSolver<TExpCalc, TThreadData, TThread, Tbarrier,
typename std::enable_if<
650 std::is_base_of<ICFEXPExplicitCalcBase , TExpCalc >::value &&
651 std::is_base_of<ICFEXPThreadDataBase , TThreadData>::value &&
652 std::is_base_of<ICFEXPThreadBase , TThread >::value &&
653 std::is_base_of<ICFEXPSynchrThreadBarrier, Tbarrier >::value>::type>
654 ::Synchronize(ESynchronization barrier)
657 _barrier[barrier]->SynchronizeThreads();
666 #define HYBRID_PARALLEL_SOLVER_EXCLUDE_THREADS 1 667 #define HYBRID_PARALLEL_SOLVER CFEXPHybridParallelSolver<CFEXPCalculation, CFEXPSolverThreadInputData, PARRALEL_SOLVER_THREAD_TEMPLATE_DEF(CFEXPCppThread, CFEXPSolverThreadInputData), CFEXPThreadGeneralBarrier> 670 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
679 virtual void Start()
override;
709 std::function<std::string(size_t)> _model_key_gttr;
716 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
722 [this](auto val1, auto val2, auto val3) {
return get_thread_instance(val1, val2, val3); }), _model_key_gttr(model_key_gttr),
723 _net_calc_service(net_service), _socket_closed(
false), _data_reader(reader) { }
727 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
732 CFEXPParallelSolver::Start();
736 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
741 return is_calc_thread ?
745 [
this](
auto it1,
auto it2) { CFEXPHybridParallelSolver::main_loop_net_communication(it1, it2); }, id, data);
749 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
756 bool calculation_end =
false;
auto calculator = get_calculator(thread_id);
757 while (!_socket_closed)
760 data->SetCalcTimeIncrement(thread_id, calculator->SimulationTimeIncrement(thread_id));
761 Synchronize(ESynchronization::eSync1);
764 check_time_synchronization(data);
766 calculation_end = check_calculation_end(data, thread_id);
767 Synchronize(ESynchronization::eSync2);
769 Synchronize(ESynchronization::eSync3);
773 Synchronize(ESynchronization::eSync4);
775 calculator->PrepareDataForNewTimeLevel(thread_id);
778 update_model_mapping(thread_id);
780 calculator->GlobalToLocalTransformation(thread_id);
781 Synchronize(ESynchronization::eSync5);
783 calculator->CalculateForces(thread_id);
784 Synchronize(ESynchronization::eSync6);
786 calculator->CalculateNewGeometry(thread_id);
787 Synchronize(ESynchronization::eSync7);
789 Synchronize(ESynchronization::eSync8);
791 calculator->StabilityControl(thread_id);
792 data->SetTimeStep(thread_id, calculator->GetCalculatedCriticTimeStep());
793 Synchronize(ESynchronization::eSync9);
795 Synchronize(ESynchronization::eSync10);
797 Synchronize(ESynchronization::eSync11);
800 catch (
const std::exception & ex)
811 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
818 bool calculation_end =
false;
819 while (!_socket_closed)
821 Synchronize(ESynchronization::eSync1 );
822 Synchronize(ESynchronization::eSync2 );
824 calculation_end = end_calculation(data);
825 Synchronize(ESynchronization::eSync3 );
829 Synchronize(ESynchronization::eSync4 );
830 Synchronize(ESynchronization::eSync5 );
831 Synchronize(ESynchronization::eSync6 );
832 Synchronize(ESynchronization::eSync7 );
834 result_export (data);
835 Synchronize(ESynchronization::eSync8 );
836 Synchronize(ESynchronization::eSync9 );
838 time_step_synchronization (data);
839 Synchronize(ESynchronization::eSync10);
842 macro_model_BB_data_send (data);
844 macro_model_calc_data_send (data);
846 macro_model_input_data_recv(data);
848 macro_model_calc_data_recv (data);
849 Synchronize(ESynchronization::eSync11);
852 catch (
const std::exception & ex)
863 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
869 auto is_end = data->CheckEnd();
872 auto instruction = _net_calc_service.ReadInstruction();
873 if (is_socket_closed(instruction))
875 if (!instruction->count(t_ENetMessage::eGetIsEndCalc))
879 auto cekey = std::string(
"ce");
882 _net_calc_service.SendInstruction(!is_end ? t_ENetMessage::eContinue : t_ENetMessage::eSetIsEndCalc, cedta);
884 result_export(data,
true);
889 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
897 try_result_export_rntm(data, forced);
900 try_result_export_full(data, forced);
905 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
911 auto instruction = _net_calc_service.ReadInstruction();
912 if (is_socket_closed(instruction))
914 if (!instruction->count(t_ENetMessage::eGetResults))
918 auto rsokey = std::string(
"rso");
922 auto nid = CFEXPBaseConvers::StringToNumber<size_t>(instruction->at(t_ENetMessage::eGetResults)->at(rsokey)->at(0));
923 auto dof = CFEXPBaseConvers::StringToNumber<size_t>(instruction->at(t_ENetMessage::eGetResults)->at(rsokey)->at(1));
931 rsodta->at(rsokey)->push_back(output);
932 _net_calc_service.SendInstruction(t_ENetMessage::eSetResults, rsodta);
936 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
942 auto instruction = _net_calc_service.ReadInstruction();
943 if (is_socket_closed(instruction))
945 if (!instruction->count(t_ENetMessage::eGetResults))
948 auto calculator = get_calculator(_calculator_map.size());
950 auto rskey = std::string(
"rs");
955 _net_calc_service.SendInstruction(t_ENetMessage::eSetResults, rsdta);
961 _builder->GetModelContainer()->IterateModElems([
this, &result](
auto item)
970 _net_calc_service.SendInstruction(t_ENetMessage::eSetResults, rsdta);
982 rsdta->at(rskey)->push_back(table_def_nd);
988 rsdta->at(rskey)->push_back(table_def_fe);
994 _net_calc_service.SendInstruction(t_ENetMessage::eSetResults, rsdta);
1000 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
1006 auto instruction = _net_calc_service.ReadInstruction();
1007 if (is_socket_closed(instruction))
1009 if (!instruction->count(t_ENetMessage::eGetStabilDt))
1013 auto dtkey = std::string(
"dt");
1014 auto mindt = data->GetMinTStep();
1017 tdata->at(dtkey)->push_back(CFEXPBaseConvers::NumberToString<t_fexpcommon_ct>(mindt));
1018 _net_calc_service.SendInstruction(t_ENetMessage::eSetStabilDt, tdata);
1021 instruction = _net_calc_service.ReadInstruction();
1022 if (is_socket_closed(instruction))
1024 if (!instruction->count(t_ENetMessage::eSetStabilDt))
1027 data->SetMinTStep(CFEXPBaseConvers::StringToNumber<t_fexpcommon_ct>(
1030 update_time_step(data);
1034 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
1041 auto bbox = std::map<size_t, Ptr<CFEXGeomTools::t_BoundBox>>();
1042 _builder->GetModelContainer()->IterateModElems([
this, &bbox](
auto item)
1044 auto id = item->GetModelId();
1045 if (!bbox.count(
id))
1054 auto bbidkey = std::string(
"bbid");
1055 auto bbdtkey = std::string(
"bbdt");
1059 auto instructionid = _net_calc_service.ReadInstruction();
1060 if (is_socket_closed(instructionid))
1062 if (!instructionid->count(t_ENetMessage::eGetBoundBoxId))
1069 _net_calc_service.SendInstruction(t_ENetMessage::eSetBoundBoxId, bbiddata);
1072 auto instructiondt = _net_calc_service.ReadInstruction();
1073 if (is_socket_closed(instructiondt))
1075 if (!instructiondt->count(t_ENetMessage::eGetBoundBox))
1083 _net_calc_service.SendInstruction(t_ENetMessage::eSetBoundBox, bbdtdata);
1088 auto instructionid = _net_calc_service.ReadInstruction();
1089 if (is_socket_closed(instructionid))
1091 if (!instructionid->count(t_ENetMessage::eGetBoundBoxId))
1096 _net_calc_service.SendInstruction(t_ENetMessage::eSetBoundBoxId, bbiddata);
1100 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
1106 auto trkeyget =
"trget";
1107 auto trkeyset =
"trset";
1108 auto reschedule =
false;
1112 auto instruction = _net_calc_service.ReadInstruction();
1113 if (is_socket_closed(instruction))
1115 if (!instruction->count(t_ENetMessage::eGetMacroModelCalcData))
1119 if (requestdata[trkeyget]->empty())
1128 auto macro = _builder->NetSerializeStructure(macro_id_str);
1129 if (!macro || macro->empty())
1132 macrocalcdata->insert(
MAP_PAIR(trkeyset, macro));
1133 _net_calc_service.SendInstruction(t_ENetMessage::eSetMacroModelCalcData, macrocalcdata);
1135 _builder->RemoveStructure(macro_id_str);
1146 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
1152 auto trkeyset =
"trset";
1157 auto instruction1 = _net_calc_service.ReadInstruction();
1158 if (is_socket_closed(instruction1))
1160 if (!instruction1->count(t_ENetMessage::eSetMacroModelId))
1164 if (requestdata1[trkeyset]->empty())
1169 auto instruction2 = _net_calc_service.ReadInstruction();
1170 if (is_socket_closed(instruction2))
1172 if (!instruction2->count(t_ENetMessage::eSetMacroModel))
1176 if (requestdata2[trkeyset]->empty())
1182 if (macro_in_data->empty())
1187 auto key =
IT.first;
1188 auto dta =
IT.second;
1198 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
1204 auto trkeyset =
"trset";
1209 auto instruction1 = _net_calc_service.ReadInstruction();
1210 if (is_socket_closed(instruction1))
1212 if (!instruction1->count(t_ENetMessage::eSetMacroModelCalcDataId))
1216 if (requestdata1[trkeyset]->empty())
1221 auto instruction2 = _net_calc_service.ReadInstruction();
1222 if (is_socket_closed(instruction2))
1224 if (!instruction2->count(t_ENetMessage::eSetMacroModelCalcData))
1231 if (macro_clc_data->empty())
1238 template<
typename TExpCalc,
typename TThreadData,
typename TThread,
typename Tbarrier>
1243 return !_socket_closed ?
1248 #endif // !_CFEXPSOLVER_H_ void thread_Calculation_function(size_t thread_id, Ptr< TThreadData > data)
Definition: FEXPSolver.h:751
virtual void SetCurrentDt(t_fexpcommon_ct dt) override
Definition: FEXPSolver.h:250
std::map< size_t, Ptr< TThread > > _thread_map
Definition: FEXPSolver.h:270
#define HYBRID_PARALLEL_SOLVER_EXCLUDE_THREADS
Definition: FEXPSolver.h:666
#define IT
Definition: FEXPCommon.h:155
#define THREAD_COUNT_UPDATER
Definition: FEXPSolver.h:515
virtual void AddModel(const t_ModelData &data)=0
bool GetIsEnd(size_t thread_id)
Definition: FEXPSolver.h:179
Definition: FEXPSerialization.h:204
static std::string GetDefOrder()
Definition: FEXPCalculationResult.h:95
virtual void End() override
It provides forced ending of a numerical simulation process (not implemented yet).
Definition: FEXPSolver.h:81
Ptr< ICFEXPResultExport > _exporter
Definition: FEXPSolver.h:50
std::function< Ptr< TThread >(size_t, Ptr< TThreadData >, bool)> t_ThrdInstGetter
Definition: FEXPSolver.h:260
virtual void AddModel(const t_ModelData &data) override
Definition: FEXPSolver.h:246
virtual void End()=0
It provides forced ending of a numerical simulation process (not implemented yet).
ESynchronization
Definition: FEXPSolver.h:256
t_fexpcommon_ct GetTimeStep(size_t thread_id)
Definition: FEXPSolver.h:174
Base setting related to the numerical simulation process.
Definition: FEXPSetting.h:57
Definition: FEXPSerialization.h:45
#define FEXPCOMMON_FOREACH(start, end, index)
Definition: FEXPCommon.h:153
#define FEXPCOMMON_KEY_TABLE_IDNTF
Definition: FEXPCommon.h:182
static std::string GetDefOrder()
Definition: FEXPCalculationResult.h:29
#define FEXPCOMMON_STACAST(clsfrom, clsto, variable)
Definition: FEXPCommon.h:137
Base interface of a data provided into each thread.
Definition: FEXPSolver.h:168
virtual Ptr< t_SerializedData > GetSerializedData()=0
virtual void RmvModel(const std::string &key)=0
virtual Ptr< t_SerializedData > GetSerializedData() override
Definition: FEXPSolver.h:89
virtual void AddModel(const t_ModelData &data) override
Definition: FEXPSolver.h:83
#define FEXPCOMMON_FOREACH_ITER_FNC(data, lambda_body)
Definition: FEXPCommon.h:157
ICFEXPSolverBase(Ptr< ICFEXPModelBuilderBase > builder, Ptr< ICFEXPResultExport > exporter)
Definition: FEXPSolver.h:27
std::atomic_bool _result_saved
Definition: FEXPSolver.h:281
Base interface for export of results.
Definition: FEXPResultExport.h:19
void SetTimeStep(size_t thread_id, t_fexpcommon_ct value)
Definition: FEXPSolver.h:175
Definition: FEXPDataContainer.h:25
virtual void SetCurrentDt(t_fexpcommon_ct dt)=0
Ptr< t_KD_def_tree< ICFEXPElementNodeBase > > _kd_tree_map
Definition: FEXPSolver.h:48
std::map< size_t, t_fexpcommon_ct > _dt_map
Definition: FEXPSolver.h:187
Definition: FEXPCommon.h:276
t_fexpcommon_ct GetMinTStep()
Definition: FEXPSolver.cpp:47
double t_fexpcommon_ct
Definition: FEXPCommon.h:120
Ptr< ICFEXPModelBuilderBase > _builder
Definition: FEXPSolver.h:49
Base interface for FE nodes.
Definition: FEXPElement.h:245
std::map< size_t, size_t > _time_consistncy_map
Definition: FEXPSolver.h:189
Definition: FEXPSolver.h:67
Definition: FEXPDataContainer.h:25
virtual void SetSerializedData(Ptr< t_SerializedData > data) override
Definition: FEXPSolver.h:90
virtual void SetSerializedData(Ptr< t_SerializedData > data)=0
virtual void RmvModel(const std::string &key) override
Definition: FEXPSolver.h:247
static t_ModelData & GetReadModelData(Ptr< std::map< size_t, Ptr< t_ModelData >>> data, size_t key)
Definition: FEXPNetworkInterface.cpp:9
size_t _threads
Definition: FEXPSolver.h:268
#define FEXPCOMMON_DEFAULT_INDX
Definition: FEXPCommon.h:171
Base interface of a solver.
Definition: FEXPSolver.h:24
virtual void SetSerializedData(Ptr< t_SerializedData > data) override
Definition: FEXPSolver.h:253
virtual void Start() override
Definition: FEXPSolver.h:729
Ptr< TThreadData > _thread_data
Definition: FEXPSolver.h:269
Ptr< TThread > get_thread_instance(size_t id, Ptr< TThreadData > data, bool is_calc_thread)
Definition: FEXPSolver.h:738
Definition: FEXPSerialization.h:204
virtual Ptr< t_SerializedData > GetSerializedData() override
Definition: FEXPSolver.h:252
virtual void SetCurrentDt(t_fexpcommon_ct dt) override
Definition: FEXPSolver.h:87
#define FEXPCOMMON_NOT_IMPLEMENTED_EX
Definition: FEXPCommon.h:144
static std::enable_if< std::is_arithmetic< TValue >::value, std::string >::type NumberToString(TValue value)
Definition: FEXPCommon.h:1079
std::map< t_ModelDataKey, Ptr< t_ModelDataDta > > t_ModelData
Definition: FEXPDataContainer.h:15
It stores the result data.
Definition: FEXPCalculationResult.h:132
std::map< size_t, bool > _is_end_map
Definition: FEXPSolver.h:188
#define FEXPCOMMON_DELIMITER
Definition: FEXPCommon.h:180
virtual ~ICFEXPSolverBase()
Definition: FEXPSolver.h:29
#define FEXPCOMMON_EXCEPTION(error_text)
Definition: FEXPCommon.h:143
Definition: FEXPDataContainer.h:25
#define FEXPCOMMON_EMPTY_STRING
Definition: FEXPCommon.h:183
virtual t_fexpcommon_ct GetCurrentDt()=0
virtual ~CFEXPSequentialSolver()
Definition: FEXPSolver.h:77
#define FEXPCOMMON_FOREACH_ITER(data)
Definition: FEXPCommon.h:156
bool CheckEnd()
Definition: FEXPSolver.cpp:67
void CheckCalcTimeConsistency()
Definition: FEXPSolver.cpp:82
Definition: FEXPSolver.h:226
Definition: FEXPDataContainer.h:25
static Ptr< TType > SafeAllocInstance(VarArgs &&... inpar)
It allocates data.
Definition: FEXPCommon.h:392
virtual void RmvModel(const std::string &key) override
Definition: FEXPSolver.h:84
#define FEXPCOMMON_KEY_BLOCK_IDNTF
Definition: FEXPCommon.h:181
virtual void Start()=0
It starts process of a numerical simulation.
#define PARALLEL_SOLVER_ERROR_THREADS
Hybrid-parallel solver (Net/CPU/GPU?).
Definition: FEXPSolver.h:671
#define DEFAULT_BB_RATIO
Definition: FEXPGeom.h:469
void SetMinTStep(t_fexpcommon_ct value)
Definition: FEXPSolver.cpp:60
#define MAP_PAIR(key, itm)
Definition: FEXPCommon.h:471
virtual ~ICFEXPThreadDataBase()
Definition: FEXPSolver.h:172
Ptr< std::vector< Ptr< ICFEXPElementNodeBase > > > check_node(const std::vector< t_fexpcommon_ct > &min_bound, const std::vector< t_fexpcommon_ct > &max_bound)
Definition: FEXPSolver.cpp:20
Base interface for system element.
Definition: FEXPDataContainer.h:28
Base container interface.
Definition: FEXPSerializeData.h:601
#define FEXPCOMMON_DEFAULT_VALUE
Definition: FEXPCommon.h:179
void update_topology_map_for_contact()
Definition: FEXPSolver.cpp:10
Network service on the client workstation side.
Definition: FEXPNetworkInterface.h:184
#define RESULT_FILE_STRUCT_BLCS
Definition: FEXPSerialization.h:184
static void WriteLine()
Definition: FEXPCommon.cpp:154
#define RESULT_FILE_STRUCT_TABS
Definition: FEXPSerialization.h:185
virtual void End() override
It provides forced ending of a numerical simulation process (not implemented yet).
Definition: FEXPSolver.h:244
Base container interface focused on processing of a serialized/deserialized data. ...
Definition: FEXPSerializeData.h:619
void SetCalcTimeIncrement(size_t thread_id, size_t value)
Definition: FEXPSolver.h:182
std::map< size_t, Ptr< TExpCalc > > _calculator_map
Definition: FEXPSolver.h:271
Smart pointer.
Definition: FEXPCommon.h:274
static std::string GetCalcBehavOutString(Ptr< ICFEXPElementNodeBase > node, size_t dof)
It composes formated output string for the monitoring of the FEXP solver behaviour.
Definition: FEXPCalculation.cpp:12
#define FEXPCOMMON_DYNCAST(clsfrom, clsto, variable)
Definition: FEXPCommon.h:138
ICFEXPThreadDataBase(size_t threads)
Definition: FEXPSolver.cpp:32
CFEXPHybridParallelSolver(std::function< Ptr< CFEXPFEInpContBase >(std::string &, Ptr< std::vector< std::string >>)> reader, Ptr< ICFEXPModelBuilderBase > builder, std::function< std::string(size_t)> model_key_gttr, ICFEXPNetClientNodeService &net_service)
Definition: FEXPSolver.h:718
virtual t_fexpcommon_ct GetCurrentDt() override
Definition: FEXPSolver.h:86
Ptr< std::vector< size_t > > GetThreadId()
Definition: FEXPSolver.cpp:99
#define FEXPCOMMON_DFLT_TXT
Definition: FEXPCommon.h:189
virtual t_fexpcommon_ct GetCurrentDt() override
Definition: FEXPSolver.h:249
void SetIsEnd(size_t thread_id, bool value)
Definition: FEXPSolver.h:180